Learn R Programming

varComp (version 0.2-0)

Internal formula manipulation: Internal formula term manipulation functions

Description

These are helper function used in the formula interface of varComp and varComp.test. They either sort or split the formula terms involving ":".

Usage

callList2terms(cl)
splitTerm(term)
sortTerm(term, priority)

Arguments

cl

A list converted from a call.

term

A character scalar of a formula term to be re-ordered alphanumerically with respect to the components separated by ":".

priority

A character vector whose elements have higher priority to be ordered to the front of the term.

Value

callList2terms returns a character vector of individual terms (possibly with duplicates). splitTerm returns a character vector of unique individual components in the term. sortTerm returns a character scalar with individual components sorted.

Details

The main use of sortTerm is to transform an interaction term like "B:A" into ordered form "A:B" such that redundant terms are easier to be identified. The results will depend on the system locale.

See Also

stats::formula

Examples

Run this code
# NOT RUN {
sortTerm("sex:ibs(SNP)")  ## ibs(SNP) is moved to the front in most locales
sortTerm("sex:ibs(SNP)", "sex")  ## the same as input
splitTerm("sex:ibs(SNP)")	## two components
sortTerm("ns(x, df=3):a:b:ibs(SNP)", "b")  

# }

Run the code above in your browser using DataLab